# The Racial Politics of Mass Incarceration

[This repository](https://github.com/ausmani23/rapol) contains replication materials for 'The Racial Politics of Mass Incarceration' by John Clegg and Adaner Usmani, forthcoming at *Perspectives on Politics*.  

Numbers indicate that files must be run in a particular order. Below we give descriptions of what each file does, and which file generates which figure. To run everything at once use 'runeverything.R'. (Note that some of the public opinion results will take a long time to run on an ordinary PC.) 

To run these files successfully, you will need to create three additional folders. 

   + '/data', which must contain the original inputs. Those can be downloaded via [this link](https://www.dropbox.com/scl/fo/gso81u2wic55g5sirxaxs/AOc6avAP7CNq14__4eBrCA8?rlkey=h6iwvn09dhwa9rn262q7581q2&dl=0]) or via the *Perspectives on Politics* [dataverse](https://doi.org/10.7910/DVN/QHVVVR) associated with the paper. 
   + '/files', which contains intermediate inputs. These will be generated by the .R files in this repository automatically, and then used as input by later .R files. 
   + '/output', which contains ultimate outputs. You will need to either modify the working directories in the .R files to store these outputs somewhere else, or create this folder. 

## Folder and File Structure

+ 'code' contains three subfolders (described below) and:

	+ dirs.R - To set file paths, relative to the location of the root directory
	+ runeverything.R - runs every file in the correct order, generating a .log file and all output used in the paper. 

+ 'code/01_public opinion' contains the code to generate the figures that correspond to Section 3. 

    + 01_group.R - Combines polling datasets
    + 02_prep.R - Recodes combined dataset
    + 03_summarize.R - Summarizes average responses by race and average black-white differences 
    + 04_summarize_output.R - Illustrates the output of 10_summarize.R. Generates Figure 1
    + 05_regmods.R - Estimates generalized linear mixed-effects models on the probability of a positive response to questions in each of the three dimensions
    + 06_regmods_output.R - Illustrates the marginal (adjusted) effect of race on p(anxious), p(mistrustful), p(punitive)
    + 07_predict.R - Combines estimates from the multilevel models with Census population data to generate predictions for each demographic cell between 1956 and 2014 
    + 08_predict_output.R - Summarizes race-specific trends over time (with and without confidence intervals) and the black-white gap (with confidence interval). Generates Figure 2
    + 09_extra_output.R - Illustrates that trends in punitiveness fit trends in crime rather than trends in civil rights activity or riots. Generates Figure 4
	+ 10_RandR_summarize.R - Illustrates robustness of descriptive inference to including/excluding respondents who gave neutral or hard-to-classify answers. Generates Figure 3
	+ 11_RandR_model.R - Runs sparser models
	+ 12_RandR_modeloutput.R - Illustrates robustness of inferences about trends to using sparser models
    + functions.R - Contains misc functions used in the scripts
    + getcode.R - Crosswalk function
    + getinfo2.R - Wrapper to getcode.R for this data
    
+ 'code/02_voting' contains the code to generate the figures that correspond to Section 4

    + 01_getvotes.R - Loads a dataset of 45 hand-coded punitive votes in the House, merges this with the universe of house votes since 1945, and uses the issue codes of the hand-coded votes to identify a sample of 'punitive' votes
    + 02_matcheos.R - Loads a dataset with information about all congressmen, merges this with a dataset on black members of congress
    + 03_merge.R - Merges the votes, members, and a members-votes dataset together
    + 04_predict.R - Trains a model using the average DW-Nominate scores of those voting 'yes' and 'no' in the hand-coded bills to predict the direction of a punitive vote in the not-hand-coded bills
    + 05_summarize.R - Summarizes levels and differences in punitive voting in the house. Generates Figures 5 and 6
    
+ 'code/03_dind' contains the code to generate the figures and results which correspond to Section 5

    + 01_dindmods.R - Estimates the effect of federally-mandated redistricting on incarceration and police rates. Runs preferred specifications and a variety of alternative specifications.
    + 02_regmods.R - Estimates the effect of black political representation on incarceration and police rates via a variety of autoregressive distributed lag (ADL) models. 
    + 03_regmods_robustness.R - Estimates a variety of alternative specifications of the ADL models.
    + 04_summarize.R - Illustrates the rise in black representation. Summarizes estimates from preferred models, from both approaches. Illustrates the robustness (or lack of robustness) of the main conclusions to alternative specifications. Generates Figure 7.
    
+ 'meta' contains files that carry metadata which is more convenient to store in spreadsheet form than in an .R script



